<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>
<%@include file="menu.jsp"%>

<script type="text/javascript" charset="utf-8" src="../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../ueditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../ueditor/lang/zh-cn/zh-cn.js"></script>

<jsp:useBean id="db" class="com.zipishu.DataBaseConnection"></jsp:useBean>

<%

 String strDesId = request.getParameter("desid");
	int desid = 0;
	String strDname = "";
	Integer areaId = 0;
	Integer emotionId = 0;
	String strAddress = "";
	String strTelephone = "";
	Integer timeId = 0;	
	String strAvgconsume = "";
    Integer shortId = 0;
    String strAbout = "";

    if(strDesId==null||"".equals(strDesId)){
    
    }else{
      desid=Integer.parseInt(strDesId);
      Connection dbcDes = db.getConnection();
	  String sqlDes = "SELECT * FROM desination where desid=?";
	  PreparedStatement stmtNews = dbcDes.prepareStatement(sqlDes);
	  stmtNews.setInt(1, desid);
	  ResultSet rsDes = stmtNews.executeQuery();
	  if(rsDes.next()){
	        strDname = rsDes.getString("name");
	        areaId = rsDes.getInt("areaid");
			emotionId = rsDes.getInt("emotionid");
			strAddress = rsDes.getString("address");
			strTelephone = rsDes.getString("telephone");
			timeId = rsDes.getInt("timeid");
			strAvgconsume = rsDes.getString("avgconsume");
			shortId = rsDes.getInt("shortid");			
			strAbout = rsDes.getString("about");
	  }
    }
       
	Connection dbcArea = db.getConnection();
	Statement stmtArea = dbcArea.createStatement();
	String sqlArea = "SELECT * FROM area";
	ResultSet rsArea = stmtArea.executeQuery(sqlArea);

	Connection dbcemo = db.getConnection();
	Statement stmtemo = dbcemo.createStatement();
	String sqlemo = "SELECT * FROM emotion";
	ResultSet rsemo = stmtemo.executeQuery(sqlemo);

	Connection dbctim = db.getConnection();
	Statement stmttim = dbctim.createStatement();
	String sqltim = "SELECT * FROM bustime";
	ResultSet rstim = stmttim.executeQuery(sqltim);
	
	Connection dbcshor = db.getConnection();
	Statement stmtshor = dbcshor.createStatement();
	String sqlshor = "SELECT * FROM shortcut";
	ResultSet rsshor = stmtshor.executeQuery(sqlshor);
	
%>

	<!-- Page Head -->
			<div class="content-box"><!-- Start Content Box -->
				
				<div class="content-box-header">
					
					<h3>添加地点</h3>
					
					<div class="clear"></div>
					
				</div> <!-- End .content-box-header -->
				
				<div class="content-box-content">
					<div class="notification information png_bg">
							<a href="#" class="close"><img src="./images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
							<div>
								随便提醒点什么, 注意事项.
							</div>
					</div>
					
					<form id="desForm" action="destinationManage_action.jsp" method="post">
							
							<fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
								
								<p>
									<label>地点名称</label>
									<input class="text-input large-input" type="text" id="name" name="name" />
								</p>
								<p>
									<label>所属地区</label>
									<select name="areaid" class="small-input">
									<% while(rsArea.next()){ %>
										<option 
										<%
										  if(rsArea.getInt("areaid") == areaId){
										    out.print("selected='selected'");
										  }
										 %>
										
										value="<%=rsArea.getInt("areaid")%>"><%=rsArea.getString("areaname")%></option>
									<% } %>
									</select> 
								</p>
								<p>
									<label>所属情绪</label>
									<select name="emotionid" class="small-input">
									<% while(rsemo.next()){ %>
										<option 
										<%
										  if(rsemo.getInt("emotionid")==emotionId){
										     out.print("selected='selected'");
										  }
										 %>
										
										value="<%=rsemo.getInt("emotionid")%>"><%=rsemo.getString("emotionname")%></option>
									<% } %>
									</select> 							
								</p>
								
								<p>
									<label>详细地址</label>
										<input class="text-input small-input" type="text" id="address" name="address" /> 
								</p>
																
								<p>
									<label>联系电话</label>              
				                 <input class="text-input small-input" type="text" id="telephone" name="telephone" /> 
			 
								</p>

								<p>
									<label>营业时间</label>
									<select name="timeid" class="small-input">
									<% while(rstim.next()){ %>
										<option 
										<%
										  if(rstim.getInt("timeid")==timeId){
										     out.print("selected='selected'");
										  }
										 %>
										
										value="<%=rstim.getInt("timeid")%>"><%=rstim.getString("timename")%></option>
									<% } %>
									</select> 							
								</p>

								<p>
									<label>人均消费</label>              
								<input class="text-input small-input" type="text" id="avgconsume" name="avgconsume" /> 
			
								</p>
			                    								<p>
									<label>快捷方式</label>              
                                    <select name="shortid" class="small-input">
									<jsp:scriptlet> while(rsshor.next()){ </jsp:scriptlet>
										<option 
										<%
										  if(rsshor.getInt("shortid")==shortId){
										     out.print("selected='selected'");
										  }
										 %>
										
										value="<%=rsshor.getInt("shortid")%>"><%=rsshor.getString("shortname") %></option>
									<jsp:scriptlet> } </jsp:scriptlet>
									</select>			
								</p>					
								<p>
									<label>地点简介</label>
									<!-- <textarea class="text-input textarea wysiwyg" id="content1" name="content1" cols="79" rows="15"></textarea> -->
									
									<script id="about" type="text/plain" style="width:100%;height:200px;"></script>

								</p>
								
								<p>
									<%if(desid == 0){%>
									<input class="button" type="submit" value="添加地点" />
								<%}else{%>
									<input type="hidden" name="desid" value="<%=desid%>" />
									<input class="button" type="submit" value="修改地点" />
								<%}%>	
								</p>
								
							</fieldset>
							
							<div class="clear"></div><!-- End .clear -->
							
						</form>
					<!-- <div class="notification information png_bg">
						<a href="#" class="close"><img src="./images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
						<div>
							一条信息
						</div>
					</div>
					
					<div class="notification success png_bg">
						<a href="#" class="close"><img src="./images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
						<div>
							成功信息
						</div>
					</div>
					
					<div class="notification attention png_bg">
						<a href="#" class="close"><img src="./images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
						<div>
							警告信息
						</div>
					</div>
					
					<div class="notification error png_bg">
						<a href="#" class="close"><img src="./images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
						<div>
							错误信息
						</div>
					</div> -->
				</div>
			</div>

		<%
		rsshor.close();	
        rstim.close();	
		rsemo.close();
		rsArea.close();


		dbcshor.close();
		dbctim.close();		
		dbcemo.close();
		dbcArea.close();
		%>
		<script type="text/javascript">
			
			$(document).ready(function(){
				
				/*如果是没有子菜单的选中，如下
				$('#admin-index').addClass('current');*/
				
				/*如果含有子菜单的，请选中父菜单和子菜单，如下*/
				$('#admin-place').addClass('current');
				$('#admin-place').parent().find("ul").slideToggle("slow");
				$('#admin-place-add').addClass('current');
				
				var ue = UE.getEditor('about');
			});
		</script>



<%@include file="footer.jsp"%>